<?php

class _F_EXTENSION_DOCS_ extends _F_EXTENSION_ {
	
	public $prev_route;

	public function __construct() {
		f()->template_path_list[] = dirname(__FILE__).'/templates';
		$this->prev_route = f()->register_method(
			'route',array($this,'route'));		
	}
	
	public function route() {
		$r = f()->request;
		if ($r === '/docs' || strpos($r,'/docs/') === 0) {
			f()->_f_route_(substr($r,6),'/extensions/docs/actions');
			f()->page_title = 'VerSimF Documentation - ';
			// reset navigation, styles and scripts			
			f()->style()->styles = array();
			f()->style('/extensions/html/styles/reset.css');
			f()->style('/extensions/html/styles/f.css');			
			f()->layout(array(
				'header' => 'docs.header',
				'layout' => 'html.twocols',
				'sidebar' => 'docs.toc',
				'footer' => 'docs.footer',
			))->style('/extensions/docs/styles/docs.less');
			f()->navigation = array(
				array('@docs','Home'),
				array('@docs/html','Html'),
			);						
		} else {
			call_user_func($this->prev_route);
		}
	}

}

new _F_EXTENSION_DOCS_;